var a = getApp();

Page({
  data: {
    name: "",
    background: ["7dcafe", "65e4d3", "65e4d3", "7dcafe"],
    background1: ["6aaeff", "43cdd8", "43cdd8", "6aaeff"],
    hiddenmodalput: !1,
    hiddenmodalput1: !1,
    creatername: "",
    Wshow: !1,
    _num: 0,
    xx: !1,
    grouping: !1,
    // 模拟人数
    sumCount: 4,
    // 人物信息
    groups: [{
        groupId: 1,
        groupName: '小花',
        principal: '小强',
        count: 1,
        userId: 1,
        userIcon: '/assets/images/head.png',
        name: '小红',
        remarkName: '心脏病',
        principal: {
          doctorName: '斐叔'
        }
      },
      {
        groupId: 1,
        groupName: '小花',
        principal: '小强',
        count: 1,
        userId: 1,
        userIcon: '/assets/images/head.png',
        name: '小红',
        remarkName: '心脏病',
        principal: {
          doctorName: '斐叔'
        }
      },
      {
        groupId: 1,
        groupName: '小花',
        principal: '小强',
        count: 1,
        userId: 1,
        userIcon: '/assets/images/head.png',
        name: '小红',
        remarkName: '心脏病',
        principal: {
          doctorName: '斐叔'
        }
      },
      {
        groupId: 1,
        groupName: '小花',
        principal: '小强',
        count: 1,
        userId: 1,
        userIcon: '/assets/images/head.png',
        name: '小红',
        remarkName: '心脏病',
        principal: {
          doctorName: '斐叔'
        }
      }
    ],
    UnbankedRegister: [{
        groupId: 1,
        groupName: '小花',
        principal: '小强',
        count: 1,
        userId: 1,
        userIcon: '/assets/images/head.png',
        name: '小红',
        remarkName: '心脏病',
        principal: {
          doctorName: '斐叔'
        }
      },
      {
        groupId: 1,
        groupName: '小花',
        principal: '小强',
        count: 1,
        userId: 1,
        userIcon: '/assets/images/head.png',
        name: '小红',
        remarkName: '心脏病',
        principal: {
          doctorName: '斐叔'
        }
      }
    ]
  },
  assign: function(a) {
    var t = this;
    1 == t.data.managerRole || 2 == t.data.managerRole ? (wx.setStorageSync("groupid", a.currentTarget.dataset.groupid),
      wx.setStorageSync("groupname", a.currentTarget.dataset.groupname), wx.navigateTo({
      url: "/hyb_yl/backstageServicess/pages/management2list/management2list"
      })) : wx.showToast({
      title: "暂无权限",
      icon: "none",
      duration: 2e3
    });
  },
  menuClick: function(a) {
    console.log(a.target.dataset), this.setData({
      _num: a.target.dataset.num,
      nmDisReason: a.target.dataset.text,
      cdDisReason: a.target.dataset.uuid
    });
  },
  wzconfirm: function(t) {
    var e = this,
      n = wx.getStorageSync("log") || "",
      o = wx.getStorageSync("teamId") || "";
    wx.request({
      url: a.globalData.dic + "doctor/team/sign/break",
      data: {
        token: n,
        patientId: e.data.patientid,
        teamId: o,
        cdDisReason: e.data.cdDisReason,
        nmDisReason: e.data.nmDisReason
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function(a) {
        console.log(a.data), 200 == a.data.code && (e.setData({
          Wshow: !1
        }), e.onClock());
      }
    });
  },
  call: function(a) {
    this.setData({
      Wshow: !1
    });
  },
  shu: function(t) {
    // console.log(t.currentTarget.dataset.patientid), wx.request({
    //   url: a.globalData.dic + "doctor/manage/showPatientAllowArchives/" + t.currentTarget.dataset.patientid,
    //   success: function(a) {
    //     if (console.log(a.data.data), 1 != a.data.data) wx.showModal({
    //       title: "提示",
    //       content: "患者没有授权",
    //       success: function(a) {
    //         a.confirm ? console.log("用户点击确定") : a.cancel && console.log("用户点击取消");
    //       }
    //     });
    //     else {
    //       wx.setStorageSync("patientId", t.currentTarget.dataset.patientid);
    //       var e = wx.getStorageSync("teamId") || "";
    //       wx.setStorageSync("flag", "2"), wx.navigateTo({
    //         url: "/hyb_yl/backstageFollowUp/pages/healthRecord/healthRecord?teamId=_" + e
    //       });
    //     }
    //   }
    // });
    wx.navigateTo({
      url: "/hyb_yl/backstageFollowUp/pages/healthRecord/healthRecord"
    });
  },
  Wmovement: function(a) {
    e = this;
    console.log("移动，解约");
    var t = a.currentTarget.dataset.patientid,
      e = this;
    wx.showActionSheet({
      itemList: ["移动到分组", "解除签约", "修改备注"],
      success: function(n) {
        0 == n.tapIndex ? 1 == e.data.managerRole || 2 == e.data.managerRole ? (wx.setStorageSync("patientid", t),
          wx.navigateTo({
          url: "/hyb_yl/backstageServicess/pages/management1/management1"
          })) : wx.showToast({
          title: "暂无权限",
          icon: "none",
          duration: 2e3
        }) : 1 == n.tapIndex ? 1 == e.data.managerRole || 2 == e.data.managerRole ? e.setData({
          Wshow: !0,
          patientid: t
        }) : wx.showToast({
          title: "暂无权限",
          icon: "none",
          duration: 2e3
        }) : 2 == n.tapIndex && (wx.setStorageSync("patientid", a.currentTarget.dataset.patientid),
          wx.setStorageSync("wznameModifier", a.currentTarget.dataset.name), wx.navigateTo({
              url: "/hyb_yl/backstageServicess/pages/casControlname1/casControlname1"
          }));
      }
    });
  },
  clickanv: function(a) {
    console.log(a.currentTarget.dataset.name), wx.setStorageSync("groupid", a.currentTarget.dataset.groupid),
      wx.setStorageSync("wzname", a.currentTarget.dataset.name), wx.navigateTo({
      url: "/hyb_yl/backstageServicess/pages/management2/management2"
      });
  },
  seet: function(a) {
    wx.navigateTo({
      url: "/hyb_yl/backstageServicess/pages/management/management"
    });
  },
  listnew: function(a) {
    var t = this;
    1 == t.data.managerRole || 2 == t.data.managerRole ? t.setData({
      hiddenmodalput: !0
    }) : wx.showToast({
      title: "暂无权限",
      icon: "none",
      duration: 2e3
    });
  },
  Winput: function(a) {
    console.log(a.detail.value), this.setData({
      name: a.detail.value
    });
  },
  Winputa: function(a) {
    console.log(a.detail.value), this.setData({
      namea: a.detail.value
    });
  },
  cancel: function() {
    this.setData({
      hiddenmodalput: !1
    });
  },
  confirm: function() {
    var t = this;
    if (wx.showLoading({
        title: "加载中",
        mask: !0
      }), "" == t.data.name) wx.showToast({
      title: "请设置分组名",
      icon: "none",
      duration: 2e3
    });
    else {
      var e = wx.getStorageSync("log") || "",
        n = wx.getStorageSync("teamId") || "";
      wx.request({
        url: a.globalData.dic + "doctor/team/manage/group/add/" + e,
        data: {
          groupName: t.data.name,
          teamId: n
        },
        method: "POST",
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        success: function(a) {
          console.log(a.data), t.setData({
            hiddenmodalput: !1,
            name: ""
          }), wx.hideLoading(), t.onClock();
        }
      });
    }
  },
  cancela: function() {
    this.setData({
      hiddenmodalput1: !1
    });
  },
  confirma: function() {
    var t = this;
    if (wx.showLoading({
        title: "加载中",
        mask: !0
      }), "" == t.data.namea) wx.showToast({
      title: "请设置分组名",
      icon: "none",
      duration: 2e3
    });
    else {
      var e = wx.getStorageSync("log") || "";
      wx.request({
        url: a.globalData.dic + "doctor/team/manage/group/update/" + e,
        data: {
          groupName: t.data.namea,
          groupId: t.data.groupid
        },
        method: "POST",
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        success: function(a) {
          console.log(a.data), t.setData({
            hiddenmodalput1: !1,
            namea: ""
          }), wx.hideLoading(), t.onClock();
        }
      });
    }
  },
  longTap: function(t) {
    var e = this;
    console.log(t), console.log(t.currentTarget.dataset.name), e.setData({
      creatername: t.currentTarget.dataset.name
    }), wx.showActionSheet({
      itemList: ["解散分组", "分组重命名"],
      success: function(n) {
        var o = wx.getStorageSync("log") || "",
          d = t.currentTarget.dataset.groupid;
        e.setData({
          groupid: t.currentTarget.dataset.groupid
        }), 0 == n.tapIndex ? 1 == e.data.managerRole || 2 == e.data.managerRole ? wx.request({
          url: a.globalData.dic + "doctor/team/manage/group/delete/" + o + "/" + d,
          success: function(a) {
            console.log(a), e.onClock();
          }
        }) : wx.showToast({
          title: "暂无权限",
          icon: "none",
          duration: 2e3
        }) : 1 == n.tapIndex && (1 == e.data.managerRole || 2 == e.data.managerRole ? e.setData({
          hiddenmodalput1: !0
        }) : wx.showToast({
          title: "暂无权限",
          icon: "none",
          duration: 2e3
        }));
      }
    });
  },
  onClock: function(t) {
    var e = this,
      n = wx.getStorageSync("log") || "",
      o = wx.getStorageSync("teamId") || "";
    wx.request({
      url: a.globalData.dic + "doctor/team/manage/list/patient/" + n + "/" + o,
      success: function(a) {
        console.log(a.data.data), e.setData({
          groups: a.data.data.groups,
          UnbankedRegister: a.data.data.unGroupPatientList,
          managerRole: a.data.data.member.managerRole,
          sumCount: a.data.data.sumCount
        }), a.data.data.groups.length <= 0 ? e.setData({
          grouping: !0
        }) : e.setData({
          grouping: !1
        }), a.data.data.unGroupPatientList.length <= 0 ? e.setData({
          xx: !0
        }) : e.setData({
          xx: !1
        }), wx.setStorageSync("managerRole", a.data.data.member.managerRole);
      }
    });
  },
  onLoad: function(t) {
    this.setData({
      teamId: wx.getStorageSync("teamId")
    });
    var e = this;
    wx.request({
      url: a.globalData.dicc + "dic/comdicbase",
      data: {
        code: 38e4
      },
      success: function(a) {
        console.log(a.data.data);
        var t = a.data.data,
          n = [],
          o = [];
        for (var d in t) n.push(t[d]), o.push(d);
        console.log(n[0]), e.setData({
          text: n,
          textID: o,
          cdDisReason: o[0],
          nmDisReason: n[0]
        });
      }
    }), e.onClock();
  },
  onShow: function() {
    this.onClock();
  },
  bindTouchStart: function(a) {
    this.startTime = a.timeStamp;
  },
  bindTouchEnd: function(a) {
    this.endTime = a.timeStamp;
  },
  onUnload: function() {
    wx.removeStorageSync("patientList"), wx.removeStorageSync("currentSaid");
  }
});